﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MongoDB.Bson;
using MongoDB.Driver;
using Newtonsoft.Json.Linq;

namespace DailyPhoto.Common
{
    
    public static class Database
    {
        static Database()
        {
            mongoClient
            = new MongoClient("mongodb://" + (string)Application.Config.database.server + ":" + (string)Application.Config.database.port);

            dailyPhotoDb =
                mongoClient.GetServer().GetDatabase("dailyphotodb");
        }

        public static MongoCollection<T> GetCollection<T>(string name)
        {
            return dailyPhotoDb.GetCollection<T>(name);
        }

        public static MongoCollection<BsonDocument> GetCollection(string name)
        {
            return dailyPhotoDb.GetCollection(name);
        }

        static MongoClient mongoClient;
        static MongoDatabase dailyPhotoDb;
    }
}
